import time
import django
class Multiple_Page():
    # 定义多页打印套数确定函数
    def Number():
        start_info = input("请在点击“打印”的同时在这里按回车开始计时\n")
        kaishi = time.time()
        one = input("请在第一套打印完成之后按下回车\n")
        ones = time.time()
        i = 0
        print("请耐心等待倒计时....")
        while True:
            dq = time.time()
            s = int(30 - (dq - ones))
            time.sleep(1)
            if s <= 5:
                print("倒计时:", s, "秒\t当计时到0的时候请取出已打印的纸张\n")
            if s <= 0:
                break
        print("已耗时30秒\n请取出已打印的纸计算份数[4张为一份,超出1张算一份]\n")

    # 定义多页打印测试函数
    def test(nub):
        start_info = input("请在点击“打印”的同时在这里按回车开始计时\n")
        kaishi = time.time()
        one = input("请在第一套打印完成之后按下回车\n")
        ones = time.time()
        i = 0
        print("请耐心等待下一个提示信息,预计25秒")
        while True:
            dq = time.time()
            s = float(30 - (dq - ones))
            time.sleep(1)
            if s <= 5:
                print("即将打印完成")
                break
        wait = input("请在打印完成之后按一下回车、\n")
        end = time.time()
        shoutao = ones - kaishi
        xiangcha = end - kaishi
        ks = end - ones
        print("首套打印完成时间:", shoutao)
        print("开始打印至最后一套打印完成时间:", xiangcha)
        print("首套打印完成时间至最后一套打印完成时间:", ks)
        g = float(nub - 1)
        i = float(30 * g)
        b = float(i / ks)
        print("本次打印套数:", int(g))
        print("本次测试速度为:", b, "ppm")

class Continuous():
    # 定义连续打印份数确定函数
    def Number():
        start_info = input("请在点击“打印”的同时在这里按回车开始计时\n")
        kaishi = time.time()
        one = input("请在第一套打印完成之后按下回车\n")
        ones = time.time()
        i = 0
        print("请耐心等待倒计时....")
        while True:
            dq = time.time()
            s = int(60 - (dq - ones))
            time.sleep(1)
            if int(s) <= 5:
                print("倒计时:", s, "秒\t当计时到0的时候请取出已打印的纸张")
            if s <= 0:
                break
        print("已耗时60秒\n请取出已打印的纸计算份数\n")

    # 定义连续打印函数
    def test():
        start_info = input("请在点击“打印”的同时在这里按回车开始计时\n")
        kaishi = time.time()
        one = input("请在第一份开始打印的时候按下回车\n")
        ones = time.time()
        i = 0
        print("请耐心等待下一个提示信息,预计55秒")
        while True:
            dq = time.time()
            s = float(60 - (dq - ones))
            time.sleep(1)
            if s <= 20:
                print("剩余20秒")
            elif s <= 10:
                print("剩余10秒")
            elif s <= 5:
                print("5秒后即将打印打印完成")
                break
        wait = input("请在打印完成之后按一下回车、\n")
        end = time.time()
        shoutao = ones - kaishi
        xiangcha = end - kaishi
        ks = end - ones
        print("首套打印完成时间:", shoutao)
        print("开始打印至最后一套打印完成时间:", xiangcha)
        print("首套打印完成时间至最后一套打印完成时间:", ks)
        g = float(nub - 1)
        i = float(30 * g)
        b = float(i / ks)
        print("本次打印套数:", int(g))
        print("本次测试速度为:", b, "ppm")


# 开始进入程序
sele = input("请选择需要进行的操作\n[1]多页打印速度测试\n[2]连续打印时间测试\n")
if sele == '1':
    se = input("请选择需要进行的操作\n[1]确定打印套数[默认]\n[2]正式测试[已确定打印套数]\n")
    if se == '2':
        nub = float(input("请输入套数\n"))
        Multiple_Page.test(nub)
    else:
        Multiple_Page.Number()

elif sele == '2':
    se = input("请选择需要进行的操作\n[1]确定打印份数[默认]\n[2]正式测试[已确定打印份数]\n")
    if se == '2':
        nub = input("请输入份数\n")
        Continuous.test(nub)
    else:
        Continuous.Number()
